package com.huawei.hms.auth.api.signin.internal.a;

import android.app.Activity;
import android.app.PendingIntent;
import android.content.Intent;
import android.content.IntentSender.SendIntentException;
import android.os.Parcelable;
import com.huawei.hms.auth.api.signin.internal.b;
import com.huawei.hms.common.internal.AnyClient;
import com.huawei.hms.common.internal.ResponseErrorCode;
import com.huawei.hms.common.internal.TaskApiCall;
import com.huawei.hms.support.common.ActivityMgr;
import com.huawei.hms.support.hianalytics.HiAnalyticsClient;
import com.huawei.hms.support.log.HMSLog;
import o.fjx;

public class a extends TaskApiCall<b, Intent> {
    public /* synthetic */ void doExecute(AnyClient anyClient, ResponseErrorCode responseErrorCode, String str, fjx o_fjx) {
        a((b) anyClient, responseErrorCode, str, o_fjx);
    }

    public a(String str, String str2, String str3) {
        super(str, str2, str3);
    }

    protected void a(b bVar, ResponseErrorCode responseErrorCode, String str, fjx<Intent> o_fjx_android_content_Intent) {
        if (responseErrorCode.getStatusCode() == 0 && responseErrorCode.getErrorCode() == 0) {
            HMSLog.i("NoticeTaskApiCall", "Jos Notice onResult success.");
            a(responseErrorCode.getParcelable());
        } else {
            HMSLog.w("NoticeTaskApiCall", "Jos Notice onResult failed:" + responseErrorCode.getErrorCode() + ",ErrReason:" + responseErrorCode.getErrorReason());
        }
        HiAnalyticsClient.reportExit(bVar.getContext(), getUri(), getTransactionId(), responseErrorCode.getStatusCode(), responseErrorCode.getErrorCode(), com.huawei.hms.auth.api.signin.internal.c.a.a());
    }

    private void a(Parcelable parcelable) {
        Activity currentActivity = ActivityMgr.INST.getCurrentActivity();
        if (currentActivity == null || currentActivity.isFinishing() || currentActivity.isDestroyed()) {
            HMSLog.i("NoticeTaskApiCall", "launchNoticeActivity failed, activity is invalid");
        } else if (parcelable instanceof Intent) {
            try {
                currentActivity.startActivity((Intent) parcelable);
            } catch (Exception e) {
                HMSLog.e("NoticeTaskApiCall", "Jos Notice startActivity meet exception");
            }
        } else if (parcelable instanceof PendingIntent) {
            try {
                currentActivity.startIntentSender(((PendingIntent) parcelable).getIntentSender(), null, 0, 0, 0);
            } catch (SendIntentException e2) {
                HMSLog.e("NoticeTaskApiCall", "Jos Notice startIntentSender meet exception");
            }
        }
    }
}
